package hu.lacimol.tutorial.todo.action;

import hu.lacimol.tutorial.todo.model.Todo;
import hu.lacimol.tutorial.todo.service.TodoService;

import java.util.Collections;
import java.util.List;

public class ViewTodoAction extends TodoAction {

	private static final long serialVersionUID = -2785052435600102817L;

	public ViewTodoAction(TodoService todoService) {
		super(todoService);
	}

	@Override
	protected String doExecute() throws Exception {
		todos = this.todoService.findAll();
		return SUCCESS;
	}

	public String doSelect() {
		final String description = request.getParameter("description");
		todos = this.todoService.find(description);
		return SUCCESS;
	}

	List<Todo> todos = Collections.emptyList();
	public List<Todo> getTodos() {
		return todos;
	}

}